home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Everything For A Hacker
/
19990506-[HACK].iso
/
DISK
/
NTCopy 1.0 (WinNT)
/
NTCopy.cpp
next >
Wrap
C/C++ Source or Header
|
1999-03-29
|
75KB
|
1,348 lines
//---------------------------------------------------------------------------
#define UNICODE
#include <vcl\condefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <winioctl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USERES("NTCopy.res");
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// NTCopy
// ╙≥ΦδΦ≥α Σδ Ωε∩Φ≡εΓαφΦ ≥ε∞εΓ NTFS ± ±ε⌡≡αφσφΦσ∞ ≤±≥αφεΓδσφφ√⌡ ∩≡αΓ Σε±≥≤∩α
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// ╬∩≡σΣσδσφΦ ΩεΣεΓ ταΓσ≡°σφΦ
//---------------------------------------------------------------------------
#define EXIT_NOT_FOUND 1 // ∩≤≥ⁿ, ⌠αΘδ ΦδΦ Ωα≥αδεπ φσ φαΘΣσφ
#define EXIT_ACCESS_DENIED 2 // Σε±≥≤∩ τα∩≡σ∙╕φ
#define EXIT_ALREADY_EXISTS 4 // ⌠αΘδ ≤µσ ±≤∙σ±≥Γ≤σ≥
#define EXIT_INCOMPATIBLE_TYPES 8 // φσ±εΓ∞σ≥Φ∞√σ ≥Φ∩√ Φ±≥ε≈φΦΩα Φ ÷σδΦ
#define EXIT_INVALID_SWITCH 16 // φσΓσ≡φε ταΣαφφ√Θ Ωδ■≈
#define EXIT_SYNTAX_ERROR 32 // ±Φφ≥αΩ±Φ≈σ±Ωα ε°ΦßΩα Γ Ωε∞αφΣφεΘ ±≥≡εΩσ
#define EXIT_NO_MEMORY 64 // φσΣε±≥α≥ε≈φε ∩α∞ ≥Φ
#define EXIT_PRIVILEGE_CHECK 96 // φσΣε±≥α≥ε≈φ√Θ ≤≡εΓσφⁿ ∩≡ΦΓΦδσπΦΘ
#define EXIT_INVALID_SYSTEM 128 // φσΣε∩≤±≥Φ∞α Γσ≡±Φ ε∩σ≡α÷ΦεφφεΘ ±Φ±≥σ∞√
#define EXIT_SYSTEM_ERROR 160 // φσ≡α±∩ετφαφφα ±Φ±≥σ∞φα ε°ΦßΩα
//---------------------------------------------------------------------------
// ╬ß∙Φσ Σαφφ√σ
//---------------------------------------------------------------------------
void* WBuffer1 = NULL; // ≤Ωατα≥σδΦ φα ≡αßε≈Φσ ß≤⌠σ≡α
void* WBuffer2 = NULL;
char* OEMBuffer = NULL; // ≤Ωατα≥σδⁿ φα ß≤⌠σ≡ ∩σ≡σΩεΣΦ≡εΓΩΦ
wchar_t* SourcePath = NULL; // ≤Ωατα≥σδⁿ φα ß≤⌠σ≡ Φ±≥ε≈φΦΩα
wchar_t* DestinationPath = NULL; // ≤Ωατα≥σδⁿ φα ß≤⌠σ≡ ∩≡Φ╕∞φΦΩα
char DiskOut = 0; // ⌠δαπ Γ√ΓεΣα Γ ΣΦ±ΩεΓ√Θ ⌠αΘδ
char UseRussian = -1; // ⌠δαπ Φ±∩εδⁿτεΓαφΦ ≡≤±±Ωεπε τ√Ωα
char OverwriteFiles = -1; // ⌠δαπ ∩σ≡στα∩Φ±Φ ±≤∙σ±≥Γ≤■∙Φ⌡ ⌠αΘδεΓ
char SkipCopy = 0; // ⌠δαπ ∩≡ε∩≤±Ωα Ωε∩Φ≡εΓαφΦ
char CopyRootRights = 0; // ⌠δαπ Ωε∩Φ≡εΓαφΦ ∩≡αΓ Σε±≥≤∩α Σδ Ωε≡φσΓεπε Ωα≥αδεπα
int ExitCode = 0; // ΩεΣ ταΓσ≡°σφΦ
WIN32_FIND_DATAW FileFinder; // ß≤⌠σ≡ Σδ ∩εΦ±Ωα ⌠αΘδεΓ
//---------------------------------------------------------------------------
// ShowAlert
// ╧≡ε÷σΣ≤≡α ⌠ε≡∞Φ≡εΓαφΦ εΩφα ∩≡σΣ≤∩≡σµΣσφΦ
//---------------------------------------------------------------------------
int ShowAlert (char* Message, UINT uIcon)
{
char* pZero = strchr (Message, 0); // φαΘ≥Φ ≡ατΣσδΦ≥σδⁿφ√Θ φεδⁿ
if (UseRussian < 0)
{
*pZero++ = '\n'; *pZero++ = '\n'; // ταßΦ≥ⁿ Σδ ΣΓ≤ τ√≈φεπε Γ√ΓεΣα
}
else
{
pZero++; pZero++; // ∩≡ε∩≤±≥Φ≥ⁿ
}
if (UseRussian <= 0) pZero = Message; // ∩σ≡σ±≥αΓΦ≥ⁿ ≤Ωατα≥σδⁿ
return MessageBoxA (GetActiveWindow (), pZero, "NTCopy", uIcon); // Γ√Γσ±≥Φ ±εεß∙σφΦσ
}
//---------------------------------------------------------------------------
// ShowSystemAlert
// ╧≡ε÷σΣ≤≡α ⌠ε≡∞Φ≡εΓαφΦ εΩφα ∩≡σΣ≤∩≡σµΣσφΦ ε ≈Φ≈≥σ∞φεΘ ε°ΦßΩσ
//---------------------------------------------------------------------------
void ShowSystemAlert (int nErrorCode)
{
char *cBuffer = stpcpy ((char*) WBuffer1, "SystemError "); // αφπδΦΘ±Ωα ±≥≡εΩα
sprintf (cBuffer, "%06d", nErrorCode); // ∩≡σεß≡ατεΓα≥ⁿ ΩεΣ ε°ΦßΩΦ
cBuffer += 6; // ∩≡ε∩≤±≥Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
*cBuffer++ = 0; *cBuffer++ = 0; // ε≥ßΦΓΩα τ√Ωα
cBuffer = stpcpy (cBuffer, "╤Φ±≥σ∞φα ε°ΦßΩα "); // ≡≤±±Ωα ±≥≡εΩα
sprintf (cBuffer, "%06d", nErrorCode); // ∩≡σεß≡ατεΓα≥ⁿ ΩεΣ ε°ΦßΩΦ
cBuffer += 6; // ∩≡ε∩≤±≥Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
*cBuffer = 0; // ταΩ≡√≥ⁿ ±≥≡εΩ≤
ShowAlert ((char*) WBuffer1, MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ ε ±≥≡α°φεΘ ε°ΦßΩσ
ExitCode |= EXIT_SYSTEM_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
}
//---------------------------------------------------------------------------
// CheckSystemVersion
// ╧≡ε÷σΣ≤≡α ∩≡εΓσ≡ΩΦ Γσ≡±ΦΦ ε∩σ≡α÷ΦεφφεΘ ±Φ±≥σ∞√
//---------------------------------------------------------------------------
BOOL CheckSystemVersion (void)
{
OSVERSIONINFOA OSVersion; // Φφ⌠ε≡∞α÷Φ ε Γσ≡±ΦΦ ±Φ±≥σ∞√
OSVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFOA); // ταΣα≥ⁿ ≡ατ∞σ≡ ±≥≡≤Ω≥≤≡√
if (!GetVersionExA (&OSVersion)) // Φφ⌠ε≡∞α÷Φ■ ε Γσ≡±ΦΦ ∩εδ≤≈Φ≥ⁿ φσ ≤Σαδε±ⁿ
{
ShowAlert ("Can'n get operating system version\0\0═σΓετ∞εµφε ε∩≡σΣσδΦ≥ⁿ Γσ≡±Φ■ ε∩σ≡α÷ΦεφφεΘ ±Φ±≥σ∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_INVALID_SYSTEM; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE;
}
if (OSVersion.dwPlatformId != VER_PLATFORM_WIN32_NT) // ²≥ε φσ Windows NT
{
ShowAlert ("This utility can work only under Windows NT\0\0▌≥α ∩≡επ≡α∞∞α ≡αßε≥ασ≥ ≥εδⁿΩε ∩εΣ ≤∩≡αΓδσφΦσ∞ Windows NT",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_INVALID_SYSTEM; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE;
}
return TRUE;
}
//---------------------------------------------------------------------------
// ParseSwitchesAlert
// ╧≡ε÷σΣ≤≡α εß≡αßε≥ΩΦ ε°ΦßΩΦ Γ Ωδ■≈σ
//---------------------------------------------------------------------------
void ParseSwitchesAlert (char* pSwitch, int ErrorMode)
{
char MBuffer[1024]; // ß≤⌠σ≡ Σδ ±εεß∙σφΦ
char* pMBuffer = stpcpy (MBuffer, "Invalid "); // ∩σ≡Γ√Θ ⌠≡απ∞σφ≥ ±εεß∙σφΦ
if (ErrorMode) // φσΓσ≡φεσ τφα≈σφΦσ Ωδ■≈α
pMBuffer = stpcpy (pMBuffer, "value of "); // ≈≥ε Φ ε≥∞σ≥Φ≥ⁿ
pMBuffer = stpcpy (pMBuffer, "switch: ");
if (strlen (pSwitch) > 20) // ±δΦ°Ωε∞ ΣδΦφφ√Θ Ωδ■≈
pMBuffer = ((char*) memcpy (pMBuffer, pSwitch, 20)) + 20; // ±Ωε∩Φ≡εΓα≥ⁿ ⌠≡απ∞σφ≥
else pMBuffer = stpcpy (pMBuffer, pSwitch); // ΣεßαΓΦ≥ⁿ Γ Ωεφσ÷
pMBuffer = stpcpy (pMBuffer, " - ignored"); // τα ΓΦ≥ⁿ ε ∩≡ε∩≤±Ωσ
*pMBuffer++ = 0; *pMBuffer++ = 0; // ≡ατΣσδΦ≥σδⁿ τ√Ωα
pMBuffer = stpcpy (pMBuffer, "═σΣε∩≤±≥Φ∞"); // ∩σ≡Γ√Θ ⌠≡απ∞σφ≥ ∩ε-≡≤±±ΩΦ
if (ErrorMode) // φσΓσ≡φεσ τφα≈σφΦσ Ωδ■≈α
pMBuffer = stpcpy (pMBuffer, "εσ τφα≈σφΦσ Ωδ■≈α: ");
else pMBuffer = stpcpy (pMBuffer, "√Θ Ωδ■≈: ");
if (strlen (pSwitch) > 20) // ±δΦ°Ωε∞ ΣδΦφφ√Θ Ωδ■≈
pMBuffer = ((char*) memcpy (pMBuffer, pSwitch, 20)) + 20; // ±Ωε∩Φ≡εΓα≥ⁿ ⌠≡απ∞σφ≥
else pMBuffer = stpcpy (pMBuffer, pSwitch); // ΣεßαΓΦ≥ⁿ Γ Ωεφσ÷
pMBuffer = stpcpy (pMBuffer, " - Ωδ■≈ ∩≡ε∩≤∙σφ"); // τα ΓΦ≥ⁿ ε ∩≡ε∩≤±Ωσ
*pMBuffer = 0; // ταΩ≡√≥ⁿ ±εεß∙σφΦσ
ShowAlert (MBuffer, MB_OK | MB_ICONWARNING); // Γ√Γσ±≥Φ ±εεß∙σφΦσ
ExitCode |= EXIT_INVALID_SWITCH; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
}
//---------------------------------------------------------------------------
// ParseSwitches
// ╧≡ε÷σΣ≤≡α ≡ατßε≡ΩΦ Ωδ■≈σΘ Ωε∞αφΣφεΘ ±≥≡εΩΦ
//---------------------------------------------------------------------------
void ParseSwitches (int argc, char** argv)
{
for (int nArg = 1; nArg < argc; ++nArg) // ÷ΦΩδ εßτε≡α ∩α≡α∞σ≥≡εΓ
{
char* pArg = argv[nArg]; // ε≈σ≡σΣφεΘ α≡π≤∞σφ≥
char cc = *pArg++; // ∩σ≡Γ√Θ ±Φ∞Γεδ
if (cc == '-' || cc == '/') // ²≥ε Ωδ■≈
{
cc = *pArg++; // Φ∞ Ωδ■≈α
if (cc == 'l' || cc == 'L') // ≤∩≡αΓδσφΦσ τ√Ωε∞
{
cc = *pArg++; // ε≈σ≡σΣφεΘ ±Φ∞Γεδ
if (cc != ':') // ²≥ε φσ ∩≡ΦτφαΩ τφα≈σφΦ
ParseSwitchesAlert (argv[nArg], (cc) ? 0 : 1); // φσΣε∩≤±≥Φ∞√Θ Ωδ■≈
else
{
cc = *pArg++; // ε≈σ≡σΣφεΘ ±Φ∞Γεδ
if (!cc || *pArg) // ±≥≡εΩα φσ ταΩεφ≈Φδα±ⁿ ΦδΦ ταΩεφ≈Φδα±ⁿ ±δΦ°Ωε∞ ≡αφε
ParseSwitchesAlert (argv[nArg], 1); // φσΣε∩≤±≥Φ∞εσ τφα≈σφΦσ Ωδ■≈α
else if (cc == 'e' || cc == 'E') // αφπδΦΘ±ΩΦΘ τ√Ω
UseRussian = 0; // ε≥∞σ≥Φ≥ⁿ
else if (cc == 'r' || cc == 'R') // ≡≤±±ΩΦΘ τ√Ω
UseRussian = 1; // ε≥∞σ≥Φ≥ⁿ
else ParseSwitchesAlert (argv[nArg], 1); // φσΣε∩≤±≥Φ∞εσ τφα≈σφΦσ Ωδ■≈α
}
}
else if (cc == 'o' || cc == 'O') // ≤∩≡αΓδσφΦσ ∩σ≡στα∩Φ±ⁿ■ ⌠αΘδεΓ
{
cc = *pArg++; // ε≈σ≡σΣφεΘ ±Φ∞Γεδ
if (cc != ':') // ²≥ε φσ ∩≡ΦτφαΩ τφα≈σφΦ
ParseSwitchesAlert (argv[nArg], (cc) ? 0 : 1); // φσΣε∩≤±≥Φ∞√Θ Ωδ■≈
else
{
cc = *pArg++; // ε≈σ≡σΣφεΘ ±Φ∞Γεδ
if (!cc || *pArg) // ±≥≡εΩα φσ ταΩεφ≈Φδα±ⁿ ΦδΦ ταΩεφ≈Φδα±ⁿ ±δΦ°Ωε∞ ≡αφε
ParseSwitchesAlert (argv[nArg], 1); // φσΣε∩≤±≥Φ∞εσ τφα≈σφΦσ Ωδ■≈α
else if (cc == 'y' || cc == 'Y') // ∩σ≡στα∩Φ±√Γα≥ⁿ
OverwriteFiles = 1; // ε≥∞σ≥Φ≥ⁿ
else if (cc == 'n' || cc == 'N') // φσ ∩σ≡στα∩Φ±√Γα≥ⁿ
OverwriteFiles = 0; // ε≥∞σ≥Φ≥ⁿ
else ParseSwitchesAlert (argv[nArg], 1); // φσΣε∩≤±≥Φ∞εσ τφα≈σφΦσ Ωδ■≈α
}
}
else if (cc == 's' || cc == 'S') // ∩≡ε∩≤±Ω Ωε∩Φ≡εΓαφΦ
{
if (*pArg) // ±≥≡εΩα φσ ταΩεφ≈Φδα±ⁿ
ParseSwitchesAlert (argv[nArg], 0); // φσΣε∩≤±≥Φ∞√Θ Ωδ■≈
else SkipCopy = 1; // ε≥∞σ≥Φ≥ⁿ
}
else if (cc == 'r' || cc == 'R') // Ωε∩Φ≡εΓα≥ⁿ ∩≡αΓα Σε±≥≤∩α Ω Ωε≡φσΓε∞≤ Ωα≥αδεπ≤
{
if (*pArg) // ±≥≡εΩα φσ ταΩεφ≈Φδα±ⁿ
ParseSwitchesAlert (argv[nArg], 0); // φσΣε∩≤±≥Φ∞√Θ Ωδ■≈
else CopyRootRights = 1; // ε≥∞σ≥Φ≥ⁿ
}
else ParseSwitchesAlert (argv[nArg], 0); // φσΣε∩≤±≥Φ∞√Θ Ωδ■≈
}
}
}
//---------------------------------------------------------------------------
// ParseTreePair
// ╧≡ε÷σΣ≤≡α Γ√ßε≡ΩΦ ∩≤≥σΘ Ωε∩Φ≡εΓαφΦ
//---------------------------------------------------------------------------
BOOL ParseTreePair (int argc, char** argv)
{
int ArgCount = 0; // ±≈╕≥≈ΦΩ α≡π≤∞σφ≥εΓ
for (int nArg = 1; nArg < argc; nArg++) // ÷ΦΩδ εßτε≡α ∩α≡α∞σ≥≡εΓ
{
char* pArg = argv[nArg]; // ε≈σ≡σΣφεΘ α≡π≤∞σφ≥
if (*pArg != '-') // ²≥ε φσ Ωδ■≈
{
if (ArgCount > 1) // ²≥ε ≤µσ δΦ°φσσ
{
ShowAlert ("Too many path arguments or syntax error in command line\0\0╙Ωαταφε ±δΦ°Ωε∞ ∞φεπε ∩≤≥σΘ ΦδΦ ±Φφ≥αΩ÷Φ≈σ±Ωα ε°ΦßΩα Γ Ωε∞σφΣφεΘ ±≥≡εΩσ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ ε φσ∩≡Φ ≥φε±≥ ⌡
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // Γσ≡φ≤≥ⁿ ⌠δαπ ε°ΦßΩΦ
}
wchar_t* cBuffer;
int nCoded;
if (!MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, pArg, -1,
(wchar_t*) WBuffer2, 10240 / sizeof (wchar_t) - 1) || // φσ ≤Σαδε±ⁿ ∩≡σεß≡ατεΓαφΦσ Γ Unicode
((nCoded = GetFullPathNameW ((wchar_t*) WBuffer2,
10240 / sizeof (wchar_t) - 1, (wchar_t*) WBuffer1, &cBuffer)) == 0)) // φσ ≤Σαδε±ⁿ ∩εδ≤≈Φ≥ⁿ ∩εδφ√Θ ∩≤≥ⁿ
{
ShowAlert ("Unicode path convertion failed\nMay be a syntax error in command line\0\0═σΓετ∞εµφε ∩≡σεß≡ατεΓα≥ⁿ ∩≤≥ⁿ Γ Unicode\n┬ετ∞εµφε, ²≥ε ±Φφ≥αΩ±Φ≈σ±Ωα ε°ΦßΩα Γ Ωε∞αφΣφεΘ ±≥≡εΩσ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ εß ε°ΦßΩσ
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // Γσ≡φ≤≥ⁿ ≡στ≤δⁿ≥α≥
}
cBuffer = ((wchar_t*) WBuffer1) + nCoded - 1; // Γ Ωεφσ÷ ±≥≡εΩΦ
if (*cBuffer++ != L'\\') // ≡ατΣσδΦ≥σδ φσ≥
*cBuffer++ = L'\\'; // ∩εΣ±≥αΓΦ≥ⁿ
if (!ArgCount) cBuffer = _wcspcpy (cBuffer, L"*.*"); // Σδ Φ±≥ε≈φΦΩα ΣεßαΓΦ≥ⁿ ∞α±Ω≤
*cBuffer = 0; // ταΩ≡√≥ⁿ ±≥≡εΩ≤
cBuffer = (wchar_t*) malloc ((wcslen ((wchar_t*) WBuffer1) + 1) * sizeof (wchar_t)); // τα⌡Γα≥Φ≥ⁿ ∩α∞ ≥ⁿ ∩εΣ ß≤⌠σ≡
if (!cBuffer) // ß≤⌠σ≡ φσ Γ√Σσδσφ
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ τα∩≤±Ωα ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ εß ε°ΦßΩσ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // Γσ≡φ≤≥ⁿ ≡στ≤δⁿ≥α≥
}
wcscpy (cBuffer, (wchar_t*) WBuffer1); // ±Ωε∩Φ≡εΓα≥ⁿ ≡στ≤δⁿ≥α≥
if (ArgCount++) DestinationPath = cBuffer; // Γ≥ε≡εΘ α≡π≤∞σφ≥ - Ω≤Σα
else SourcePath = cBuffer; // ∩σ≡Γ√Θ α≡π≤∞σφ≥ - ε≥Ω≤Σα
}
}
return TRUE; // Γ±╕ Γ√∩εδφσφε
}
//---------------------------------------------------------------------------
// WriteLogString
// ╧≡ε÷σΣ≤≡α Γ√ΓεΣα ±≥≡εΩΦ Γ ⌠αΘδ ∩≡ε≥εΩεδα
//---------------------------------------------------------------------------
void WriteLogString (char* LString, BOOL bBreak)
{
char* pBuffer = LString; // ∩≡σΣ∩εδαπασ∞ Γ√ΓεΣ φα ΣΦ±Ω
if (!DiskOut) // φσ≥, Γ≡εΣσ ß√ φα ²Ω≡αφ
{
CharToOemA (LString, OEMBuffer); // ∩≡σεß≡ατεΓα≥ⁿ
pBuffer = OEMBuffer; // ∩εΣ∞σφΦ≥ⁿ ≤Ωατα≥σδⁿ
}
printf ("%s", pBuffer); // Γ√Γσ±≥Φ
if (bBreak) printf ("\n"); // φα ±δσΣ≤■∙≤■ ±≥≡εΩ≤
}
//---------------------------------------------------------------------------
// WriteLogMessage
// ╧≡ε÷σΣ≤≡α Γ√ΓεΣα ∞φεπε τ√≈φεπε ∩≡ε≥εΩεδα
//---------------------------------------------------------------------------
void WriteLogMessage (char* EString, char* RString)
{
if (UseRussian <= 0) WriteLogString (EString, TRUE); // Γ√Γσ±≥Φ αφπδΦΘ±Ω≤■ ±≥≡εΩ≤
if (UseRussian) WriteLogString (RString, TRUE); // Γ√Γσ±≥Φ ≡≤±±Ω≤■ ±≥≡εΩ≤
}
//---------------------------------------------------------------------------
// WriteLogFile
// ╧≡ε÷σΣ≤≡α Γ√ΓεΣα Γ ∩≡ε≥εΩεδ Φ∞σφΦ ⌠αΘδα
//---------------------------------------------------------------------------
void WriteLogFile (wchar_t* FileString, void* WBuffer, BOOL bBreak)
{
int nCoded = WideCharToMultiByte (CP_ACP, 0, FileString, -1, (char*) WBuffer,
10230, NULL, NULL); // ∩≡σεß≡ατεΓα≥ⁿ Φ∞ ⌠αΘδα
if (!nCoded) // ∩≡σεß≡ατεΓαφΦσ φσ Γ√∩εδφσφε
*((char*) WBuffer) = 0; // επ≡αφΦ≈Φ≥σδⁿ
WriteLogString ((char*) WBuffer, bBreak); // Γ√Γσ±≥Φ
}
//---------------------------------------------------------------------------
// LogFileAlert
// ╧≡ε÷σΣ≤≡α Γ√ΓεΣα Γ ∩≡ε≥εΩεδ ±εεß∙σφΦΘ εß ε°ΦßΩα⌡
//---------------------------------------------------------------------------
void LogFileAlert (wchar_t* FileString, void* WBuffer, char* EString, char* ETrail,
char* RString, char* RTrail)
{
if (UseRussian <= 0) // ≡ατ≡σ°╕φ αφπδΦΘ±ΩΦΘ τ√Ω
{
WriteLogString (EString, FALSE); // φα≈αδε ±εεß∙σφΦ
WriteLogFile (FileString, WBuffer, FALSE); // Φ∞ ⌠αΘδα
WriteLogString (ETrail, TRUE); // ⌡Γε±≥ ±εεß∙σφΦ
}
if (UseRussian) // ≡ατ≡σ°╕φ ≡≤±±ΩΦΘ τ√Ω
{
WriteLogString (RString, FALSE); // φα≈αδε ±εεß∙σφΦ
WriteLogFile (FileString, WBuffer, FALSE); // Φ∞ ⌠αΘδα
WriteLogString (RTrail, TRUE); // ⌡Γε±≥ ±εεß∙σφΦ
}
}
//---------------------------------------------------------------------------
// ShowFileAlert
// ╧≡ε÷σΣ≤≡α Γ√ΓεΣα ±εεß∙σφΦ ±ε ±∩σ÷Φ⌠ΦΩα÷ΦσΘ ⌠αΘδα
//---------------------------------------------------------------------------
int ShowFileAlert (wchar_t* FileString, int nStrLength, char* EString, char* ETrail,
char* RString, char* RTrail, UINT uIcon)
{
wchar_t* sBuffer = FileString; // Φ±⌡εΣφα ±≥≡εΩα
if (nStrLength >= 0) // Γτ ≥ⁿ ≈α±≥ⁿ ±≥≡εΩΦ
{
sBuffer = (wchar_t*) WBuffer2; // ∩≡ε∞σµ≤≥ε≈φ√Θ ß≤⌠σ≡
if (nStrLength) memcpy (WBuffer2, FileString, nStrLength * sizeof (wchar_t)); // ±Ωε∩Φ≡εΓα≥ⁿ ≈α±≥ⁿ ±≥≡εΩΦ
sBuffer[nStrLength] = 0; // ταΩ≡√≥ⁿ ±≥≡εΩ≤
}
char* cBuffer = (char*) WBuffer1; // ß≤⌠σ≡ ∩≡σεß≡ατεΓαφΦ
*cBuffer++ = ':'; *cBuffer++ = '\n'; // ΓΓεΣφ√σ ±Φ∞Γεδ√
int nCoded = WideCharToMultiByte (CP_ACP, 0, sBuffer, -1, cBuffer, 10230,
NULL, NULL); // ∩≡σεß≡ατεΓα≥ⁿ ∩≤≥ⁿ
if (!nCoded) // ∩≡σεß≡ατεΓαφΦσ φσ Γ√∩εδφσφε
*((char*) WBuffer1) = 0; // επ≡αφΦ≈Φ≥σδⁿ
cBuffer = (char*) WBuffer2; // Γ≥ε≡εΘ ß≤⌠σ≡
cBuffer = stpcpy (cBuffer, EString); // αφπδΦΘ±Ωα ±≥≡εΩα ±εεß∙σφΦ
cBuffer = stpcpy (cBuffer, (char*) WBuffer1); // Φ∞ ⌠αΘδα
cBuffer = stpcpy (cBuffer, ETrail); // αφπδΦΘ±ΩΦΘ ⌡Γε±≥ ±εεß∙σφΦ
*cBuffer++ = 0; *cBuffer++ = 0; // ≡ατΣσδΦ≥σδⁿ τ√ΩεΓ
cBuffer = stpcpy (cBuffer, RString); // ≡≤±±Ωα ±≥≡εΩα ±εεß∙σφΦ
cBuffer = stpcpy (cBuffer, (char*) WBuffer1); // Φ∞ ⌠αΘδα
stpcpy (cBuffer, RTrail); // ≡≤±±ΩΦΘ ⌡Γε±≥ ±εεß∙σφΦ
return ShowAlert ((char*) WBuffer2, uIcon); // Γ√Γσ±≥Φ ±εεß∙σφΦσ
}
//---------------------------------------------------------------------------
// Concatenate
// ╧≡ε÷σΣ≤≡α ±δΦ φΦ ±≥≡εΩ
//---------------------------------------------------------------------------
wchar_t* Concatenate (wchar_t* S1, int n1, wchar_t* S2, int n2, wchar_t* S3, int n3)
{
if (n1 < 0) n1 = wcslen (S1); // ε∩≡σΣσδΦ≥ⁿ Φ±≥Φφφ√σ ≡ατ∞σ≡√ ±≥≡εΩ
if (n2 < 0) n2 = wcslen (S2);
if (n3 < 0) n3 = wcslen (S3);
wchar_t* Sp = (wchar_t*) malloc ((n1 + n2 + n3 + 1) * sizeof (wchar_t)); // τα⌡Γα≥Φ≥ⁿ ∩α∞ ≥ⁿ
if (Sp) // ∩α∞ ≥ⁿ Γ√Σσδσφα
{
wchar_t* pSp = Sp; // ±Ωε∩Φ≡εΓα≥ⁿ φα≈αδⁿφ√Θ ≤Ωατα≥σδⁿ
if (n1 > 0) pSp = ((wchar_t*) memcpy (pSp, S1, n1 * sizeof (wchar_t))) + n1; // ∩σ≡Γα ∩εΣ±≥≡εΩα
if (n2 > 0) pSp = ((wchar_t*) memcpy (pSp, S2, n2 * sizeof (wchar_t))) + n2; // Γ≥ε≡α ∩εΣ±≥≡εΩα
if (n3 > 0) pSp = ((wchar_t*) memcpy (pSp, S3, n3 * sizeof (wchar_t))) + n3; // ≥≡σ≥ⁿ ∩εΣ±≥≡εΩα
*pSp = 0; // ταΩ≡√≥ⁿ ±≥≡εΩ≤
}
return Sp; // Γσ≡φ≤≥ⁿ ≡στ≤δⁿ≥α≥
}
//---------------------------------------------------------------------------
// GetPathLength
// ╧≡ε÷σΣ≤≡α ε∩≡σΣσδσφΦ ΣδΦφ√ ∩≤≥Φ
//---------------------------------------------------------------------------
int GetPathLength (wchar_t* FString)
{
int nResult = 0; // ≡στ≤δⁿ≥α≥
int nIndex = 0; // ΦφΣσΩ± ∩σ≡σßε≡α
while (FString[nIndex]) // Γ± ±≥≡εΩα Σε Ωεφ÷α
{
if (FString[nIndex++] == L'\\') // εßφα≡≤µσφ ≡ατΣσδΦ≥σδⁿ
nResult = nIndex; // τα⌠ΦΩ±Φ≡εΓα≥ⁿ ΣδΦφ≤
}
return nResult; // Γσ≡φ≤≥ⁿ ≡στ≤δⁿ≥α≥
}
//---------------------------------------------------------------------------
// TransferCompressionStatus
// ╧≡ε÷σΣ≤≡α ∩σ≡σφε±α ±ε±≥ε φΦ Ωε∞∩≡σ±±ΦΦ
//---------------------------------------------------------------------------
BOOL TransferCompressionStatus (wchar_t* PSource, wchar_t* PDest)
{
USHORT StatusBuffer; // ß≤⌠σ≡ Σδ ±≈Φ≥√ΓαφΦ ±≥α≥≤±α
DWORD nResult; // ß≤⌠σ≡ Σδ ≡στ≤δⁿ≥α≥α ε∩σ≡α÷ΦΦ
int nErrorCode; // Σδ ΩεΣα ε°ΦßΩΦ
DWORD dwAttrib = GetFileAttributesW (PSource); // ∩εδ≤≈Φ≥ⁿ α≥≡Φß≤≥√ Φ±≥ε≈φΦΩα
if (dwAttrib == 0xFFFFFFFF) // φσ ∩≡ε≈Φ≥αδΦ±ⁿ
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PSource, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
HANDLE hPtr = CreateFileW (PSource, 0,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL); // ε≥Ω≡√≥ⁿ Φ±≥ε≈φΦΩ
if (hPtr == INVALID_HANDLE_VALUE) // ε≥Ω≡√≥ⁿ φσ ∩εδ≤≈Φδε±ⁿ
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PSource, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
BOOL bExStat = DeviceIoControl (hPtr, FSCTL_GET_COMPRESSION, NULL, 0,
&StatusBuffer, sizeof (USHORT), &nResult, NULL); // ∩≡ε≈Φ≥α≥ⁿ ±≥α≥≤± Φ±≥ε≈φΦΩα
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
CloseHandle (hPtr); // ταΩ≡√≥ⁿ ≤Ωατα≥σδⁿ
if (!bExStat) // ≈≥σφΦ φσ ∩εδ≤≈Φδε±ⁿ
{
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
if (!SetFileAttributesW (PDest, FILE_ATTRIBUTE_NORMAL)) // Γ≡σ∞σφφε ±ß≡ε±Φ≥ⁿ α≥≡Φß≤≥√ φσ ∩εδ≤≈Φδε±ⁿ
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
hPtr = CreateFileW (PDest, GENERIC_WRITE,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL); // ε≥Ω≡√≥ⁿ Φ±≥ε≈φΦΩ
if (hPtr == INVALID_HANDLE_VALUE) // ε≥Ω≡√≥ⁿ φσ ∩εδ≤≈Φδε±ⁿ
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
bExStat = DeviceIoControl (hPtr, FSCTL_SET_COMPRESSION,
&StatusBuffer, sizeof (USHORT), NULL, 0, &nResult, NULL); // ≤±≥αφεΓΦ≥ⁿ ±≥α≥≤± ∩≡Φ╕∞φΦΩα
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
CloseHandle (hPtr); // ταΩ≡√≥ⁿ ≤Ωατα≥σδⁿ
if (!bExStat) // ≈≥σφΦ φσ ∩εδ≤≈Φδε±ⁿ
{
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
if (!SetFileAttributesW (PDest, dwAttrib)) // φσ ≤±≥αφεΓΦδΦ±ⁿ φ≤µφ√σ α≥≡Φß≤≥√
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
return TRUE; // Γ√∩εδφσφε
}
//---------------------------------------------------------------------------
// TransferFile
// ╧≡ε÷σΣ≤≡α Ωε∩Φ≡εΓαφΦ ε≈σ≡σΣφεπε ⌠αΘδα
//---------------------------------------------------------------------------
BOOL TransferFile (wchar_t* PSource, wchar_t* PDest)
{
char DFlag = 0; // ⌠δαπ ε°ΦßΩΦ ± ∩εδ≤≈α≥σδσ∞
int nErrorCode = 0; // ΩεΣ ε°ΦßΩΦ
if (OverwriteFiles <= 0) // ∩σ≡στα∩Φ±ⁿ ≥≡σß≤σ≥± ΩαΩ ∞ΦφΦ∞≤∞ ∩εΣ≥Γσ≡ΣΦ≥ⁿ
{
DWORD dwAttrib = GetFileAttributesW (PDest); // ∩≡εΓσ≡Φ≥ⁿ φαδΦ≈Φσ ÷σδσΓεπε ⌠αΘδα
if (dwAttrib == 0xFFFFFFFF) // α≥≡Φß≤≥√ φσ ∩εδ≤≈σφ√
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
else
{
if (dwAttrib & FILE_ATTRIBUTE_DIRECTORY) // ²≥ε Ωα≥αδεπ
{
ExitCode |= EXIT_INCOMPATIBLE_TYPES; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "Directory already exists, file cannot be copied",
"", "╙µσ ±≤∙σ±≥Γ≤σ≥ Ωα≥αδεπ, φσΓετ∞εµφε ±Ωε∩Φ≡εΓα≥ⁿ ⌠αΘδ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return FALSE; // ∩≡σ≡Γα≥ⁿ ε∩σ≡α÷Φ■
LogFileAlert (PDest, WBuffer1, "Directory already exists, file cannot be copied: ",
" - skipped", "╙µσ ±≤∙σ±≥Γ≤σ≥ Ωα≥αδεπ, φσΓετ∞εµφε ±Ωε∩Φ≡εΓα≥ⁿ ⌠αΘδ: ",
" - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return TRUE; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
int nReply = (!OverwriteFiles) ? IDNO :
ShowFileAlert (PDest, -1, "File already exists", "\nOverwrite?",
"╘αΘδ ≤µσ ±≤∙σ±≥Γ≤σ≥", "\n╧σ≡σ∩Φ±α≥ⁿ?",
MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2); // ≈≥ε Σσδα≥ⁿ?
if (nReply != IDYES) ExitCode |= EXIT_ALREADY_EXISTS; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (nReply == IDCANCEL) return FALSE; // ∩≡σ≡Γα≥ⁿ ε∩σ≡α÷Φ■
if (nReply == IDNO) // ∩σ≡στα∩Φ±ⁿ ßδεΩΦ≡εΓαφα
{
LogFileAlert (PDest, WBuffer1, "File already exists: ",
" - skipped", "╘αΘδ ≤µσ ±≤∙σ±≥Γ≤σ≥: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return TRUE; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (!SetFileAttributesW (PDest, FILE_ATTRIBUTE_NORMAL)) // ±ß≡ε±Φ≥ⁿ α≥≡Φß≤≥√ φσ ∩εδ≤≈Φδε±ⁿ
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
}
if (nErrorCode == ERROR_FILE_NOT_FOUND) nErrorCode = 0; // ²≥ε φσ ε°ΦßΩα
DFlag = (nErrorCode != 0); // ⌠δαπ ε°ΦßΩΦ
}
if (!nErrorCode && // ∞εµφε Ωε∩Φ≡εΓα≥ⁿ
!CopyFileW (PSource, PDest, FALSE)) // α ±Ωε∩Φ≡εΓα≥ⁿ φσ ∩εδ≤≈Φδε±ⁿ
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if (nErrorCode == ERROR_FILE_EXISTS) // ⌠αΘδ ±≤∙σ±≥Γ≤σ≥
{
ExitCode |= EXIT_ALREADY_EXISTS; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "File already exists and cannot be overwritten", "",
"╘αΘδ ≤µσ ±≤∙σ±≥Γ≤σ≥ Φ φσ ∞εµσ≥ ß√≥ⁿ ∩σ≡σ∩Φ±αφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return FALSE; // ∩≡σ≡Γα≥ⁿ ε∩σ≡α÷Φ■
LogFileAlert (PDest, WBuffer1, "File already exists and cannot be overwritten: ",
" - skipped", "╘αΘδ ≤µσ ±≤∙σ±≥Γ≤σ≥ Φ φσ ∞εµσ≥ ß√≥ⁿ ∩σ≡σ∩Φ±αφ: ",
" - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return TRUE; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
}
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert ((DFlag) ? PDest : PSource, -1,
"File or path not found", "", "╘αΘδ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return FALSE;
LogFileAlert ((DFlag) ? PDest : PSource, WBuffer1, "File or path not found: ",
" - skipped", "╘αΘδ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return TRUE; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert ((DFlag) ? PDest : PSource, -1, "Access denied", "",
"─ε±≥≤∩ τα∩≡σ∙╕φ", "", MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return FALSE;
LogFileAlert ((DFlag) ? PDest : PSource, WBuffer1, "Access denied: ",
" - file skipped", "─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - ⌠αΘδ ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return TRUE; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert ((DFlag) ? PDest : PSource, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if (nErrorCode) // ≡ατßε≡ ε°ΦßεΩ
{
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
if (!TransferCompressionStatus (PSource, PDest)) return FALSE; // ε°ΦßΩα ∩σ≡σφε±α ±ε±≥ε φΦ ±µα≥Φ
WriteLogFile (PSource, WBuffer1, FALSE); // ⌠αΘδ-Φ±≥ε≈φΦΩ
WriteLogString (" => ", FALSE); // ≡ατΣσδΦ≥σδⁿ
WriteLogFile (PDest, WBuffer1, TRUE); // ÷σδσΓεΘ ⌠αΘδ
return TRUE; // Γ√∩εδφσφε
}
//---------------------------------------------------------------------------
// MakeTargetDirectory
// ╧≡ε÷σΣ≤≡α ±ετΣαφΦ ÷σδσΓεπε ∩εΣΩα≥αδεπα
//---------------------------------------------------------------------------
int MakeTargetDirectory (wchar_t* PSource, wchar_t* PDest)
{
int nLength = GetPathLength (PDest); // Γ√ΣσδΦ≥ⁿ ΣδΦφ≤ ±εß±≥Γσφφε ∩≤≥Φ
DWORD dwAttrib = GetFileAttributesW (PDest); // ∩≡εΓσ≡Φ≥ⁿ φαδΦ≈Φσ ⌠αΘδα / Ωα≥αδεπα
if ((dwAttrib == 0xFFFFFFFF) || !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) // Ωα≥αδεπα ≥ε≈φε φσ≥
{
if (dwAttrib != 0xFFFFFFFF) // ≤Γ√, Φ∞σσ≥± ⌠αΘδ
{
ExitCode |= EXIT_INCOMPATIBLE_TYPES; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "File already exists, directory cannot be created", "",
"╙µσ ±≤∙σ±≥Γ≤σ≥ ⌠αΘδ, φσΓετ∞εµφε ±ετΣα≥ⁿ Ωα≥αδεπ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1; // ⌠δαπ ε≥∞σφ√
LogFileAlert (PDest, WBuffer1, "File already exists, directory cannot be created: ",
" - skipped", "╙µσ ±≤∙σ±≥Γ≤σ≥ ⌠αΘδ, φσΓετ∞εµφε ±ετΣα≥ⁿ Ωα≥αδεπ: ",
" - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡ε∩≤±≥Φ≥ⁿ
}
int nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if (nErrorCode == ERROR_FILE_NOT_FOUND) // ε≥±≤≥±≥ΓΦσ ⌠αΘδα - ²≥ε φε≡∞αδⁿφε
nErrorCode = CreateDirectoryW (PDest, NULL) ? 0 : GetLastError (); // ±ετΣα≥ⁿ Ωα≥αδεπ
if ((nErrorCode == ERROR_PATH_NOT_FOUND) || (nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, nLength, "Path not found", "", "╧≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PDest, WBuffer1, "Path not found: ", " - directory skipped",
"╧≤≥ⁿ φσ φαΘΣσφ: ", " - Ωα≥αδεπ ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, nLength, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PDest, WBuffer1, "Access denied: ", " - directory skipped",
"─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - Ωα≥αδεπ ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, nLength, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if (nErrorCode) // ε°ΦßΩα
{
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return -1; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
}
if (!TransferCompressionStatus (PSource, PDest)) return -1; // ε°ΦßΩα ∩σ≡σφε±α ±ε±≥ε φΦ ±µα≥Φ
if (dwAttrib == 0xFFFFFFFF) // Ωα≥αδεπ ±ετΣαΓαδ±
{
WriteLogFile (PSource, WBuffer1, FALSE); // Ωα≥αδεπ-Φ±≥ε≈φΦΩ
WriteLogString ("\\ => ", FALSE); // ≡ατΣσδΦ≥σδⁿ
}
else
{
WriteLogFile (PSource, WBuffer1, FALSE); // Ωα≥αδεπ-Φ±≥ε≈φΦΩ
WriteLogString ("\\ == ", FALSE); // ≡ατΣσδΦ≥σδⁿ
}
WriteLogFile (PDest, WBuffer1, FALSE); // ÷σδσΓεΘ Ωα≥αδεπ
WriteLogString ("\\", TRUE); // ≡ατΣσδΦ≥σδⁿ
return 1; // Γ√∩εδφσφε
}
//---------------------------------------------------------------------------
// TransferAccessRights
// ╧≡ε÷σΣ≤≡α Ωε∩Φ≡εΓαφΦ ∩≡αΓ Σε±≥≤∩α Σδ ε≈σ≡σΣφεπε ⌠αΘδα ΦδΦ Ωα≥αδεπα
//---------------------------------------------------------------------------
int TransferAccessRights (wchar_t* PSource, wchar_t* PDest)
{
int nErrorCode; // ΩεΣ ε°ΦßΩΦ
DWORD dwDAttrib = GetFileAttributesW (PDest); // ∩εδ≤≈Φ≥ⁿ α≥≡Φß≤≥√ ÷σδσΓεπε ⌠αΘδα
if (dwDAttrib == 0xFFFFFFFF) // φσ ∩εδ≤≈σφ√
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
if (!SkipCopy) return 0; // φσ ß√δε ±Ωε∩Φ≡εΓαφε - τφα≈Φ≥, ≥αΩ φαΣε
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1; // ∩≡σ≡Γα≥ⁿ
LogFileAlert (PDest, WBuffer1, "File, directory or path not found: ",
" - skipped", "╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∩≡εΣεδµΦ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PDest, WBuffer1, "Access denied: ", " - skipped",
"─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return -1; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return -1; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
DWORD dwSAttrib = GetFileAttributesW (PSource); // ∩εδ≤≈Φ≥ⁿ α≥≡Φß≤≥√ Φ±≥ε≈φΦΩα
if (dwSAttrib == 0xFFFFFFFF) // φσ ∩εδ≤≈σφ√
{
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PSource, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1; // ∩≡σ≡Γα≥ⁿ
LogFileAlert (PSource, WBuffer1, "File, directory or path not found: ",
" - skipped", "╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∩≡εΣεδµΦ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PSource, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PSource, WBuffer1, "Access denied: ", " - skipped",
"─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PSource, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return -1; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return -1; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
dwDAttrib &= FILE_ATTRIBUTE_DIRECTORY; // ε±≥αΓΦ≥ⁿ ≥εδⁿΩε ∩≡ΦτφαΩ Ωα≥αδεπα
dwSAttrib &= FILE_ATTRIBUTE_DIRECTORY;
if (dwDAttrib != dwSAttrib) // φσ ±εΓ∩αΣα■≥ ≥Φ∩√ εß·σΩ≥εΓ
{
if (!SkipCopy) return 0; // φσ ß√δε ±Ωε∩Φ≡εΓαφε - τφα≈Φ≥, ≥αΩ φαΣε
ExitCode |= EXIT_INCOMPATIBLE_TYPES; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PSource, -1, (dwSAttrib) ? "Target is not a directory" : "Target is not a file",
"", (dwSAttrib) ? "╓σδσΓεΘ εß·σΩ≥ φσ Γδ σ≥± Ωα≥αδεπε∞" : "╓σδσΓεΘ εß·σΩ≥ φσ Γδ σ≥± ⌠αΘδε∞",
"", MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
if (UseRussian <= 0) // φ≤µσφ αφπδΦΘ±ΩΦΘ ≥σΩ±≥
{
WriteLogFile (PSource, WBuffer1, FALSE); // ⌠αΘδ-Φ±≥ε≈φΦΩ
WriteLogString ((dwSAttrib) ? "\\ - target is not a directory " : " - target is not a file ", FALSE);
WriteLogFile (PDest, WBuffer1, FALSE); // ÷σδσΓεΘ ⌠αΘδ
WriteLogString ((dwDAttrib) ? "\\" : "", FALSE); // ταΩδ■≈Φ≥σδⁿφ√Θ ≡ατΣσδΦ≥σδⁿ
WriteLogString (" - skipped", TRUE);
}
if (UseRussian) // φ≤µσφ ≡≤±±ΩΦΘ ≥σΩ±≥
{
WriteLogFile (PSource, WBuffer1, FALSE); // ⌠αΘδ-Φ±≥ε≈φΦΩ
WriteLogString ((dwSAttrib) ? "\\ - ÷σδσΓεΘ εß·σΩ≥ φσ Γδ σ≥± Ωα≥αδεπε∞ " : " - ÷σδσΓεΘ εß·σΩ≥ φσ Γδ σ≥± ⌠αΘδε∞ ", FALSE);
WriteLogFile (PDest, WBuffer1, FALSE); // ÷σδσΓεΘ ⌠αΘδ
WriteLogString ((dwDAttrib) ? "\\" : "", FALSE); // ταΩδ■≈Φ≥σδⁿφ√Θ ≡ατΣσδΦ≥σδⁿ
WriteLogString (" - ∩≡ε∩≤∙σφ", TRUE);
}
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
DWORD nLengthNeeded = 0; // ß≤⌠σ≡ Σδ ε∩≡σΣσδσφΦ ≡ατ∞σ≡α ε∩Φ±α≥σδ
PSECURITY_DESCRIPTOR pSecurity = NULL; // ≤Ωατα≥σδⁿ φα ε∩Φ±α≥σδⁿ ∩≡αΓ Σε±≥≤∩α
nErrorCode = 0; // ε°ΦßεΩ ∩εΩα φσ≥
if (!GetFileSecurityW (PSource,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION,
(PSECURITY_DESCRIPTOR) WBuffer1, 0, &nLengthNeeded)) // φσ ≤Σα╕≥± ∩≡ε≈Φ≥α≥ⁿ Φφ⌠ε≡∞α÷Φ■ ε ∩≡αΓα⌡ Σε±≥≤∩α
{
nErrorCode = GetLastError (); // ε∩≡σΣσδΦ≥ⁿ ΩεΣ ε°ΦßΩΦ
if ((nErrorCode == ERROR_INSUFFICIENT_BUFFER) ||
(nErrorCode == ERROR_BUFFER_OVERFLOW)) // φσΣε±≥α≥ε≈φ√Θ ≡ατ∞σ≡ ß≤⌠σ≡α
nErrorCode = 0; // ≥αΩ Φ Σεδµφε ß√≥ⁿ
}
if (!nErrorCode) // ∩σ≡Γ√Θ Γ√τεΓ ∩≡ε°╕δ
{
if (!nLengthNeeded) return 0; // φΦ≈σπε φσ φαΣε Ωε∩Φ≡εΓα≥ⁿ
pSecurity = (PSECURITY_DESCRIPTOR) malloc (nLengthNeeded); // τα⌡Γα≥Φ≥ⁿ ∩α∞ ≥ⁿ Σδ ε∩Φ±α≥σδ
if (!pSecurity) // ∩α∞ ≥ⁿ φσ Γ√Σσδσφα
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ Γ√∩εδφσφΦ ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
DWORD nBufferLength = nLengthNeeded; // τα∩ε∞φΦ≥ⁿ ≡ατ∞σ≡ ß≤⌠σ≡α
if (!GetFileSecurityW (PSource,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION,
pSecurity, nBufferLength, &nLengthNeeded)) // Φφ⌠ε≡∞α÷Φ φσ ∩≡ε≈Φ≥αφα
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
else if (nLengthNeeded > nBufferLength) nErrorCode = ERROR_INSUFFICIENT_BUFFER; // φσ ⌡Γα≥Φδε ∩α∞ ≥Φ
}
if (nErrorCode && pSecurity) free (pSecurity); // ∩≡Φ ε°ΦßΩσ ß≤⌠σ≡ φσ φ≤µσφ
if ((nErrorCode == ERROR_INSUFFICIENT_BUFFER) ||
(nErrorCode == ERROR_BUFFER_OVERFLOW)) // φσΣε±≥α≥ε≈φ√Θ ≡ατ∞σ≡ ß≤⌠σ≡α
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ Γ√∩εδφσφΦ ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PSource, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1; // ∩≡σ≡Γα≥ⁿ
LogFileAlert (PSource, WBuffer1, "File, directory or path not found: ",
" - skipped", "╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∩≡εΣεδµΦ≥ⁿ
}
if ((nErrorCode == ERROR_ACCESS_DENIED) ||
(nErrorCode == 1314) || (nErrorCode == 1307)) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PSource, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PSource, WBuffer1, "Access denied: ", " - skipped",
"─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PSource, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if (nErrorCode) // Γ±╕-≥αΩΦ ΩαΩα -≥ε ε°ΦßΩα
{
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return -1; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
if (!SetFileSecurityW (PDest,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION,
pSecurity)) // ∩≡αΓα Σε±≥≤∩α φσ τα∩Φ±α≥ⁿ
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
free (pSecurity); // ε±ΓεßεΣΦ≥ⁿ ß≤⌠σ≡
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_PATH_NOT_FOUND) ||
(nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ ΦδΦ ⌠αΘδ
{
if (!SkipCopy) return 0; // φσ ß√δε ±Ωε∩Φ≡εΓαφε - τφα≈Φ≥, ≥αΩ φαΣε
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "File, directory or path not found", "",
"╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1; // ∩≡σ≡Γα≥ⁿ
LogFileAlert (PDest, WBuffer1, "File, directory or path not found: ",
" - skipped", "╘αΘδ, Ωα≥αδεπ ΦδΦ ∩≤≥ⁿ φσ φαΘΣσφ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∩≡εΣεδµΦ≥ⁿ
}
if ((nErrorCode == ERROR_ACCESS_DENIED) ||
(nErrorCode == 1314) || (nErrorCode == 1307)) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
if (ShowFileAlert (PDest, -1, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) // ±εεß∙Φ≥ⁿ - ε≥∞σφα
return -1;
LogFileAlert (PDest, WBuffer1, "Access denied: ", " - skipped",
"─ε±≥≤∩ τα∩≡σ∙╕φ: ", " - ∩≡ε∩≤∙σφ"); // Γ√Γσ±≥Φ Γ ∩≡ε≥εΩεδ
return 0; // ∞εµφε ∩≡εΣεδµα≥ⁿ
}
if (nErrorCode == ERROR_NOT_ENOUGH_MEMORY) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PDest, -1, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return -1; // ∩≡σ≡Γα≥ⁿ
}
if (nErrorCode) // Γ±╕-≥αΩΦ ΩαΩα -≥ε ε°ΦßΩα
{
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return -1; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
WriteLogFile (PSource, WBuffer1, FALSE); // ⌠αΘδ-Φ±≥ε≈φΦΩ
WriteLogString ((dwDAttrib) ? "\\ => " : " => ", FALSE); // ≡ατΣσδΦ≥σδⁿ
WriteLogFile (PDest, WBuffer1, FALSE); // ÷σδσΓεΘ ⌠αΘδ
WriteLogString ((dwSAttrib) ? "\\" : "", TRUE); // ταΓσ≡°Φ≥ⁿ ±≥≡εΩ≤
return 1; // Γ√∩εδφσφε
}
//---------------------------------------------------------------------------
// ScanTree
// ╧≡ε÷σΣ≤≡α ±ΩαφΦ≡εΓαφΦ Σσ≡σΓα Ωα≥αδεπεΓ Φ ∩σ≡σφε±α ⌠αΘδεΓ / ∩≡αΓ
//---------------------------------------------------------------------------
BOOL ScanTree (wchar_t* PSource, wchar_t* PDest, int nPass)
{
int nLength = GetPathLength (PSource); // επ≡αφΦ≈σφΦσ ΣδΦφ√ ±∩σ÷Φ⌠ΦΩα÷ΦΦ
HANDLE FindHandle = FindFirstFileW (PSource, &FileFinder); // φαΘ≥Φ ∩σ≡Γ√Θ ⌠αΘδ
DWORD nErrorCode = GetLastError (); // φα Γ± ΩΦΘ ±δ≤≈αΘ ΩεΣ ε°ΦßΩΦ
if (FindHandle != INVALID_HANDLE_VALUE) // ⌠αΘδ φαΘΣσφ
{
BOOL bExStat = TRUE; // ⌠δαπ Γ√∩εδφσφΦ
while (bExStat) // ∩εΩα ⌠αΘδ εßφα≡≤µΦΓασ≥±
{
char cError = 0; // ⌠δαπ ε°ΦßΩΦ
wchar_t* SourceSpec = Concatenate (PSource, nLength, FileFinder.cFileName, -1,
PSource, 0); // ±⌠ε≡∞Φ≡εΓα≥ⁿ ±∩σ÷Φ⌠ΦΩα÷Φ■ Φ±≥ε≈φΦΩα
wchar_t* DestSpec = Concatenate (PDest, -1, FileFinder.cFileName, -1, PDest, 0); // ±⌠ε≡∞Φ≡εΓα≥ⁿ ÷σδσΓ≤■ ±∩σ÷Φ⌠ΦΩα÷Φ■
if (!SourceSpec || !DestSpec) // ∩α∞ ≥ⁿ φσ Γ√Σσδσφα
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ Γ√∩εδφσφΦ ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
cError = 1; // ε≥∞σ≥Φ≥ⁿ ε°ΦßΩ≤
}
else if (FileFinder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // ²≥ε Ωα≥αδεπ
{
if (wcscmp (FileFinder.cFileName, L".") &&
wcscmp (FileFinder.cFileName, L"..")) // ²≥ε φσ ±δ≤µσßφ√σ τα∩Φ±Φ
{
if (nPass == 1) // Ωε∩Φ≡εΓαφΦσ ∩εΣΩα≥αδεπεΓ
{
int nFlag = MakeTargetDirectory (SourceSpec, DestSpec); // ±ετΣα≥ⁿ ÷σδσΓεΘ ∩εΣΩα≥αδεπ
if (nFlag < 0) cError = 1; // ±σ≡ⁿ╕τφα ε°ΦßΩα
else if (nFlag) // ∩εΣΩα≥αδεπ ±ετΣαφ ΦδΦ ≤µσ ±≤∙σ±≥Γ≤σ≥
{
free (SourceSpec); free (DestSpec); // ε±ΓεßεΣΦ≥ⁿ ß≤⌠σ≡α
SourceSpec = Concatenate (PSource, nLength,
FileFinder.cFileName, -1, L"\\*.*", -1); // ∞α±Ωα Σδ ∩εΦ±Ωα Γφ≤≥≡Φ
DestSpec = Concatenate (PDest, -1, FileFinder.cFileName, -1,
L"\\", -1); // ÷σδσΓεΘ Ωα≥αδεπ
if (!SourceSpec || !DestSpec) // ∩α∞ ≥ⁿ φσ Γ√Σσδσφα
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ Γ√∩εδφσφΦ ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
cError = 1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
else if (!ScanTree (SourceSpec, DestSpec, 0) ||
!ScanTree (SourceSpec, DestSpec, 1)) // ±ßεΘ ∩≡Φ Ωε∩Φ≡εΓαφΦΦ ∩εΣΩα≥αδεπα
cError = 1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
}
else if (nPass == 3) // Ωε∩Φ≡εΓαφΦσ ∩≡αΓ Σε±≥≤∩α Ω ∩εΣΩα≥αδεπα∞
{
int nFlag = TransferAccessRights (SourceSpec, DestSpec); // ±Ωε∩Φ≡εΓα≥ⁿ ∩≡αΓα Σε±≥≤∩α
if (nFlag < 0) cError = 1; // ε≥∞σ≥Φ≥ⁿ ε°ΦßΩ≤
else if (nFlag) // ≤⌡εΣ Γπδ≤ßⁿ Γετ∞εµσφ
{
free (SourceSpec); free (DestSpec); // ε±ΓεßεΣΦ≥ⁿ ß≤⌠σ≡α
SourceSpec = Concatenate (PSource, nLength,
FileFinder.cFileName, -1, L"\\*.*", -1); // ∞α±Ωα Σδ ∩εΦ±Ωα Γφ≤≥≡Φ
DestSpec = Concatenate (PDest, -1, FileFinder.cFileName, -1,
L"\\", -1); // ÷σδσΓεΘ Ωα≥αδεπ
if (!SourceSpec || !DestSpec) // ∩α∞ ≥ⁿ φσ Γ√Σσδσφα
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ Γ√∩εδφσφΦ ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
cError = 1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
else if (!ScanTree (SourceSpec, DestSpec, 2) ||
!ScanTree (SourceSpec, DestSpec, 3)) // ±ßεΘ ∩≡Φ Ωε∩Φ≡εΓαφΦΦ ∩εΣΩα≥αδεπα
cError = 1; // ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
}
}
}
}
else
{
if (nPass == 0) // Ωε∩Φ≡εΓαφΦσ ⌠αΘδεΓ
{
if (!TransferFile (SourceSpec, DestSpec)) // ⌠αΘδ φσ ±Ωε∩Φ≡εΓαφ
cError = 1; // ε≥∞σ≥Φ≥ⁿ
}
else if (nPass == 2) // Ωε∩Φ≡εΓαφΦσ ∩≡αΓ Σε±≥≤∩α Ω ⌠αΘδα∞
{
int nFlag = TransferAccessRights (SourceSpec, DestSpec); // ±Ωε∩Φ≡εΓα≥ⁿ ∩≡αΓα Σε±≥≤∩α
if (nFlag < 0) cError = 1; // ε≥∞σ≥Φ≥ⁿ ε°ΦßΩ≤
}
}
if (SourceSpec) free (SourceSpec); // ε±ΓεßεΣΦ≥ⁿ Γ√Σσδσφφ≤■ ∩α∞ ≥ⁿ
if (DestSpec) free (DestSpec);
if (cError) return FALSE; // ∩≡Φ ε°ΦßΩσ ∩≡σ≡Γα≥ⁿ Γ√∩εδφσφΦσ
bExStat = FindNextFileW (FindHandle, &FileFinder); // φαΘ≥Φ ±δσΣ≤■∙ΦΘ ⌠αΘδ
}
nErrorCode = GetLastError (); // ∩εδ≤≈Φ≥ⁿ ΩεΣ ε°ΦßΩΦ
if (!FindClose (FindHandle)) // φσ ∩εδ≤≈Φδε±ⁿ ταΩ≡√≥ⁿ ∩εΦ±Ω
{
ShowSystemAlert (GetLastError ()); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
}
if ((nErrorCode == ERROR_FILE_NOT_FOUND) || (nErrorCode == ERROR_NO_MORE_FILES)) // ²≥ε φε≡∞αδⁿφε
return TRUE;
if ((nErrorCode == ERROR_PATH_NOT_FOUND) || (nErrorCode == 67)) // φσ φαΘΣσφ ∩≤≥ⁿ
{
ExitCode |= EXIT_NOT_FOUND; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, nLength, "Path not found", "", "╧≤≥ⁿ φσ φαΘΣσφ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if (nErrorCode == ERROR_ACCESS_DENIED) // τα∩≡σ∙╕φ Σε±≥≤∩
{
ExitCode |= EXIT_ACCESS_DENIED; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return (ShowFileAlert (PSource, nLength, "Access denied", "", "─ε±≥≤∩ τα∩≡σ∙╕φ", "",
MB_OKCANCEL | MB_ICONWARNING) == IDOK); // ±εεß∙Φ≥ⁿ
}
if ((nErrorCode == ERROR_NOT_ENOUGH_MEMORY) ||
(nErrorCode == ERROR_NO_MORE_SEARCH_HANDLES)) // φσ ⌡Γα≥Φδε ≡σ±≤≡±εΓ
{
ShowAlert ("Insufficient memory or system resources\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ ΦδΦ ±Φ±≥σ∞φ√⌡ ≡σ±≤≡±εΓ",
MB_OK | MB_ICONSTOP); // ±εεß∙Φ≥ⁿ
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
if ((nErrorCode == ERROR_INVALID_DRIVE) || (nErrorCode == ERROR_INVALID_NAME)) // ε°ΦßΩα Γ ±∩σ÷Φ⌠ΦΩα÷ΦΦ ⌠αΘδα
{
ExitCode |= EXIT_SYNTAX_ERROR; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
ShowFileAlert (PSource, nLength, "Invalid drive or another error in path", "",
"═σΣε±≥≤∩φεσ ≤±≥≡εΘ±≥Γε ΦδΦ Σ≡≤πα ε°ΦßΩα Γ ταΣαφΦΦ ∩≤≥Φ", "",
MB_OK | MB_ICONWARNING); // ±εεß∙Φ≥ⁿ
return FALSE; // ∩≡σ≡Γα≥ⁿ
}
ShowSystemAlert (nErrorCode); // ±εεß∙Φ≥ⁿ ε ±Φ±≥σ∞φεΘ ε°ΦßΩσ
return FALSE; // ∩≡σ≡Γα≥ⁿ ≡αßε≥≤
}
//---------------------------------------------------------------------------
// GetPrivileges
// ╧≡ε÷σΣ≤≡α ≤±≥αφεΓΩΦ φσεß⌡εΣΦ∞√⌡ ∩≡ΦΓΦδσπΦΘ ∩≡ε÷σ±±α
// Know-How: Mark Russinovich and Bryce Cogswell
//---------------------------------------------------------------------------
BOOL GetPrivileges (void)
{
HANDLE Client;
int j;
wchar_t* P[] = { // ±∩Φ±εΩ φσεß⌡εΣΦ∞√⌡ ∩≡ΦΓΦδσπΦΘ
SE_TAKE_OWNERSHIP_NAME,
SE_SECURITY_NAME,
SE_BACKUP_NAME,
SE_RESTORE_NAME,
SE_MACHINE_ACCOUNT_NAME,
SE_CHANGE_NOTIFY_NAME
};
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES, &Client)) // ε≥Ω≡√≥ⁿ ∞α≡Ωσ≡ ßστε∩α±φε±≥Φ ∩≡ε÷σ±±α
return FALSE; // φσ ≤Σαδε±ⁿ
TOKEN_PRIVILEGES* Priv = (TOKEN_PRIVILEGES*) WBuffer1; // ß≤⌠σ≡ Σδ ⌠ε≡∞Φ≡εΓαφΦ ±≥≡≤Ω≥≤≡√
for (j = 0; j < sizeof (P) / sizeof (P[0]); ++j) // Γ±σ φσεß⌡εΣΦ∞√σ ∩≡ΦΓΦδσπΦΦ
{
if (!LookupPrivilegeValueW (NULL, P[j], &Priv->Privileges[j].Luid)) // ∩εδ≤≈Φ≥ⁿ ΦΣσφ≥Φ⌠ΦΩα≥ε≡ ∩≡ΦΓΦδσπΦΦ
{
CloseHandle (Client); // ταΩ≡√≥ⁿ ∞α≡Ωσ≡
return FALSE; // ∩≡ΦΓΦδσπΦ φσ εßφα≡≤µσφα
}
Priv->Privileges[j].Attributes = SE_PRIVILEGE_ENABLED; // ∩≡ΦΓΦδσπΦ■ ΓΩδ■≈Φ≥ⁿ
}
Priv->PrivilegeCount = sizeof (P) / sizeof (P[0]); // ≈Φ±δε ∩≡ΦΓΦδσπΦΘ
BOOL bExStat = AdjustTokenPrivileges (Client, FALSE, Priv, 0, NULL, NULL); // τα∩≡ε±Φ≥ⁿ ≤±≥αφεΓΩ≤ ∩≡ΦΓΦδσπΦΘ
CloseHandle (Client); // ταΩ≡√≥ⁿ ∞α≡Ωσ≡
return bExStat; // Γσ≡φ≤≥ⁿ ≡στ≤δⁿ≥α≥
}
//---------------------------------------------------------------------------
// ╬±φεΓφα ∩≡ε÷σΣ≤≡α
//---------------------------------------------------------------------------
int main (int argc, char** argv)
{
ParseSwitches (argc, argv); // ≡ατεß≡α≥ⁿ Ωδ■≈Φ
{
HANDLE StdOutHandle = GetStdHandle (STD_OUTPUT_HANDLE); // ∩εδ≤≈Φ≥ⁿ ΦΣσφ≥Φ⌠ΦΩα≥ε≡ ±≥αφΣα≡≥φεπε Γ√ΓεΣα
if (StdOutHandle != INVALID_HANDLE_VALUE) // ≈≥ε-≥ε ∩εδ≤≈σφε
DiskOut = (GetFileType (StdOutHandle) == FILE_TYPE_DISK); // ε≥∞σ≥Φ≥ⁿ Γ√ΓεΣ φα ΣΦ±Ω
}
WBuffer1 = malloc (10240); // τα⌡Γα≥Φ≥ⁿ ≡αßε≈Φσ ß≤⌠σ≡α
WBuffer2 = malloc (10240);
if (!DiskOut) OEMBuffer = (char*) malloc (5120);
if (!WBuffer1 || !WBuffer2 || (!DiskOut && !OEMBuffer)) // φ≤µφ√σ ß≤⌠σ≡α φσ τα⌡Γα≈σφ√
{
ShowAlert ("Insufficient memory\0\0═σΣε±≥α≥ε≈φε ∩α∞ ≥Φ Σδ τα∩≤±Ωα ∩≡επ≡α∞∞√",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_NO_MEMORY; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
}
else if (CheckSystemVersion ()) // ²≥ε Windows NT
{
if (ParseTreePair (argc, argv) && SourcePath && DestinationPath) // ∩≤≥Φ ≤±∩σ°φε Γ√Σσδσφ√
{
if (!GetPrivileges ()) // φσ ≤Σαδε±ⁿ ∩εδ≤≈Φ≥ⁿ φσεß⌡εΣΦ∞√σ ∩≡ΦΓΦδσπΦΦ
{
ShowAlert ("Unable to obtain necessary privilege\0═σΓετ∞εµφε ∩εδ≤≈Φ≥ⁿ φσεß⌡εΣΦ∞√σ Σδ ≡αßε≥√ ∩≡ΦΓΦδσπΦΦ",
MB_OK | MB_ICONSTOP);
ExitCode |= EXIT_PRIVILEGE_CHECK; // ≤±≥αφεΓΦ≥ⁿ ΩεΣ ταΓσ≡°σφΦ
}
else
{
BOOL bExStat = TRUE; // ∩εΩα Γ±╕ ⌡ε≡ε°ε
if (!SkipCopy) // Ωε∩Φ≡εΓαφΦσ φσ ∩≡ε∩≤∙σφε
{
WriteLogMessage ("Copying files and folders:",
"╩ε∩Φ≡εΓαφΦσ ⌠αΘδεΓ Φ Ωα≥αδεπεΓ:"); // ταπεδεΓεΩ ∩≡ε≥εΩεδα
bExStat = ScanTree (SourcePath, DestinationPath, 0); // ∩σ≡σφσ±≥Φ ⌠αΘδ√
if (bExStat) bExStat =
ScanTree (SourcePath, DestinationPath, 1); // Φ ∩εΣΩα≥αδεπΦ
}
if (bExStat) // Ωε∩Φ≡εΓαφΦσ φσ ±δσ≥σδε
{
WriteLogMessage ("Copying user access rights:",
"╩ε∩Φ≡εΓαφΦσ ∩≡αΓ Σε±≥≤∩α ∩εδⁿτεΓα≥σδσΘ:"); // ταπεδεΓεΩ ∩≡ε≥εΩεδα
bExStat = ScanTree (SourcePath, DestinationPath, 2); // ∩σ≡σφσ±≥Φ ∩≡αΓα φα ⌠αΘδ√
if (bExStat) bExStat = ScanTree (SourcePath, DestinationPath, 3); // Φ ∩εΣΩα≥αδεπΦ
if (bExStat && CopyRootRights) // ≥≡σß≤σ≥± Ωε∩Φ≡εΓαφΦσ ∩≡αΓ Σε±≥≤∩α Ω Ωε≡φσΓε∞≤ Ωα≥αδεπ≤
{
wchar_t* LastSlash = wcsrchr (SourcePath, L'\\'); // φαΘ≥Φ ∩ε±δσΣφΦΘ ≡ατΣσδΦ≥σδⁿ
*(++LastSlash) = 0; // ε≥±σ≈ⁿ τΓστΣε≈ΩΦ
if (wcslen (SourcePath) > 3) *(--LastSlash) = 0; // ≤ß≡α≥ⁿ ≡ατΣσδΦ≥σδⁿ, σ±δΦ ²≥ε φσ Ωε≡σφⁿ ΣΦ±Ωα
LastSlash = wcsrchr (DestinationPath, L'\\'); // φαΘ≥Φ ∩ε±δσΣφΦΘ ≡ατΣσδΦ≥σδⁿ
if (wcslen (DestinationPath) > 3) *LastSlash = 0; // ≤ß≡α≥ⁿ ≡ατΣσδΦ≥σδⁿ, σ±δΦ ²≥ε φσ Ωε≡σφⁿ ΣΦ±Ωα
TransferAccessRights (SourcePath, DestinationPath); // Ωε∩Φ≡εΓα≥ⁿ ∩≡αΓα Σε±≥≤∩α Σδ Ωε≡φ
}
}
}
}
else
{
if (UseRussian <= 0) // Σε∩≤±≥Φ∞ αφπδΦΘ±ΩΦΘ
{
WriteLogString ("\nNTCopy 1.0 - Copying files with user access rights\n", TRUE);
WriteLogString ("Usage:\n\tNTCopy [-switch] SourcePath [-switch] DestinationPath [-switch]", TRUE);
WriteLogString ("\nBoth SourcePath and DestinationPath are paths to the folders (may be relative)\nand can't contain wildcards", TRUE);
WriteLogString ("\nAvailable switches:", TRUE);
WriteLogString ("\t-l:e|r\tswitches to English or Russian language; uses both as default", TRUE);
WriteLogString ("\t-o:y|n\tenables (y) or disables (n) an overwriting of existing files;\n\t\tprompts to the user as default", TRUE);
WriteLogString ("\t-s\tskips file copying and sets user access rights for existing\n\t\tfiles", TRUE);
WriteLogString ("\t-r\tcopies user access rights for root directory", TRUE);
WriteLogString ("\nYou can use both uppercase and lowercase characters to set switches", TRUE);
}
if (UseRussian) // Σε∩≤±≥Φ∞ ≡≤±±ΩΦΘ
{
WriteLogString ("\nNTCopy 1.0 - ╩ε∩Φ≡εΓαφΦσ ⌠αΘδεΓ ± ∩≡αΓα∞Φ Σε±≥≤∩α ∩εδⁿτεΓα≥σδσΘ\n", TRUE);
WriteLogString ("┬√τεΓ:\n\tNTCopy [-Ωδ■≈] ╧≤≥ⁿ╬≥Ω≤Σα [-Ωδ■≈] ╧≤≥ⁿ╩≤Σα [-Ωδ■≈]", TRUE);
WriteLogString ("\n╧≤≥ⁿ╬≥Ω≤Σα Φ ╧≤≥ⁿ╩≤Σα - ²≥ε ∩≤≥Φ Ω Ωα≥αδεπα∞ (Γετ∞εµφε, ε≥φε±Φ≥σδⁿφ√σ);\nΓ φΦ⌡ φσδⁿτ Φ±∩εδⁿτεΓα≥ⁿ ±Φ∞Γεδ√ π≡≤∩∩εΓ√⌡ ε∩σ≡α÷ΦΘ", TRUE);
WriteLogString ("\n─ε∩≤±≥Φ∞√σ Ωδ■≈Φ:", TRUE);
WriteLogString ("\t-l:e|r\t∩σ≡σΩδ■≈ασ≥ ∩≡επ≡α∞∞≤ φα αφπδΦΘ±ΩΦΘ (e) ΦδΦ ≡≤±±ΩΦΘ (r) τ√Ω;\n\t\t∩ε ≤∞εδ≈αφΦ■ Φ±∩εδⁿτ≤■≥± εßα τ√Ωα ±εΓ∞σ±≥φε", TRUE);
WriteLogString ("\t-o:y|n\t≡ατ≡σ°ασ≥ (y) ΦδΦ τα∩≡σ∙ασ≥ (n) ∩σ≡στα∩Φ±ⁿ ±≤∙σ±≥Γ≤■∙Φ⌡ ⌠αΘδεΓ;\n\t\t∩ε ≤∞εδ≈αφΦ■ ∩εδⁿτεΓα≥σδ■ ταΣα╕≥± Γε∩≡ε±", TRUE);
WriteLogString ("\t-s\t∩≡ε∩≤±Ωασ≥ Ωε∩Φ≡εΓαφΦσ ⌠αΘδεΓ Φ ≤±≥αφαΓδΦΓασ≥ ∩≡αΓα Σε±≥≤∩α\n\t\tΣδ ±≤∙σ±≥Γ≤■∙Φ⌡ ⌠αΘδεΓ", TRUE);
WriteLogString ("\t-r\tΩε∩Φ≡≤σ≥ ∩≡αΓα Σε±≥≤∩α Σδ Ωε≡φσΓεπε Ωα≥αδεπα", TRUE);
WriteLogString ("\n─δ ≤ΩαταφΦ Ωδ■≈σΘ Γ√ ∞εµσ≥σ Φ±∩εδⁿτεΓα≥ⁿ ±Φ∞Γεδ√ Γσ≡⌡φσπε Φ φΦµφσπε ≡σπΦ±≥≡α", TRUE);
}
}
}
if (SourcePath) free (SourcePath); // ε±ΓεßεΣΦ≥ⁿ ß≤⌠σ≡α
if (DestinationPath) free (DestinationPath);
if (OEMBuffer) free (OEMBuffer);
if (WBuffer1) free (WBuffer1);
if (WBuffer2) free (WBuffer2);
return ExitCode;
}
//---------------------------------------------------------------------------